package com.example.strategy;

import com.example.entity.enums.CouponTypeEnum;

import java.util.EnumMap;

public class DiscountStrategy {

    private final static EnumMap<CouponTypeEnum, Discount> strategies;

    static {
        strategies = new EnumMap<>(CouponTypeEnum.class);
        strategies.put(CouponTypeEnum.NO_THRESHOLD, new NoThresholdDiscount());
        strategies.put(CouponTypeEnum.RATE_DISCOUNT, new RateDiscount());
        strategies.put(CouponTypeEnum.PRICE_DISCOUNT, new PriceDiscount());
    }

    public static Discount getDiscount(CouponTypeEnum type) {
        return strategies.get(type);
    }
}
